package com.ruoyi.generator.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 读取代码生成相关配置
 *
 * @author rrms
 */
@Component
@ConfigurationProperties(prefix = "gen")
@PropertySource(value = {"classpath:generator.yml"})
public class GenConfig {
    /**
     * 作者
     */
    private static String author;

    /**
     * 生成包路径
     */
    private static String packageName;

    /**
     * 代码生成位置
     */
    private static String genPath;

    /**
     * 自动去除表前缀，默认是false
     */
    private static boolean autoRemovePre;

    /**
     * 表前缀(类名不会包含表前缀)
     */
    private static String tablePrefix;

    public static String getAuthor() {
        return author;
    }

    @Value("${author}")
    public void setAuthor(String author) {
        GenConfig.author = author;
    }

    public static String getPackageName() {
        return packageName;
    }

    @Value("${packageName}")
    public void setPackageName(String packageName) {
        GenConfig.packageName = packageName;
    }

    public static String getGenPath() {
        return genPath;
    }

    @Value("${genPath}")
    public void setGenPath(String genPath) {
        GenConfig.genPath = genPath;
    }

    public static boolean getAutoRemovePre() {
        return autoRemovePre;
    }

    @Value("${autoRemovePre}")
    public void setAutoRemovePre(boolean autoRemovePre) {
        GenConfig.autoRemovePre = autoRemovePre;
    }

    public static String getTablePrefix() {
        return tablePrefix;
    }

    @Value("${tablePrefix}")
    public void setTablePrefix(String tablePrefix) {
        GenConfig.tablePrefix = tablePrefix;
    }

    /**
     * 模块名称controller
     */
    private static String moduleControllerName;
    /**
     * 模块页面vue
     */
    private static String moduleVueName;

    public static String getModuleControllerName() {
        return moduleControllerName;
    }

    @Value("${moduleControllerName}")
    public void setModuleControllerName(String moduleControllerName) {
        GenConfig.moduleControllerName = moduleControllerName;
    }

    public static String getModuleVueName() {
        return moduleVueName;
    }

    @Value("${moduleVueName}")
    public void setModuleVueName(String moduleVueName) {
        GenConfig.moduleVueName = moduleVueName;
    }

    /**
     * 模块名称
     */
    private static String controllerPackageName;

    public static String getControllerPackageName() {
        return controllerPackageName;
    }

    @Value("${controllerPackageName}")
    public void setControllerPackageName(String controllerPackageName) {
        GenConfig.controllerPackageName = controllerPackageName;
    }

}
